import businessApi from '@/api/declaration/crm/businessApi'
import httpRequest from '@/config/axios/httpRequest'
import { BpmBusinessModel } from '@/models/bpm/BpmBusinessModel'
import { CrmTransferReqModel } from '@/models/crm/CrmTransferReqModel'

// 查询 CRM 商机列表
export const getBusinessPage = async (params) => {
  return await httpRequest.get(businessApi.GetBusinessPage, { params })
}

// 查询 CRM 商机列表，基于指定客户
export const getBusinessPageByCustomer = async (params) => {
  return await httpRequest.get(businessApi.GetBusinessPageByCustomer, { params })
}

// 查询 CRM 商机详情
export const getBusiness = async (id: number) => {
  return await httpRequest.get(businessApi.GetBusiness, { params: { id } })
}

// 获得 CRM 商机列表（精简）
export const getSimpleBusinessList = async () => {
  return await httpRequest.get(businessApi.GetSimpleBusinessList)
}

// 新增 CRM 商机
export const createBusiness = async (data: BpmBusinessModel) => {
  return await httpRequest.post(businessApi.CreateBusiness, data)
}

// 修改 CRM 商机
export const updateBusiness = async (data: BpmBusinessModel) => {
  return await httpRequest.put(businessApi.UpdateBusiness, data)
}

// 修改 CRM 商机状态
export const updateBusinessStatus = async (data: BpmBusinessModel) => {
  return await httpRequest.put(businessApi.UpdateBusinessStatus, data)
}
// 删除 CRM 商机
export const deleteBusiness = async (id: number) => {
  return await httpRequest.delete(businessApi.DeleteBusiness, { params: { id } })
}

// 导出 CRM 商机 Excel
export const exportBusiness = async (params) => {
  return await httpRequest.get(businessApi.ExportBusiness, { params })
}

// 联系人关联商机列表
export const getBusinessPageByContact = async (params) => {
  return await httpRequest.get(businessApi.GetBusinessPageByContact, { params })
}

// 商机转移
export const transferBusiness = async (data: CrmTransferReqModel) => {
  return await httpRequest.put(businessApi.TransferBusiness, data)
}
